package com.bit.inmap;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.SimpleExpandableListAdapter;
import android.widget.TextView;

public class CurriculumActivity extends Activity implements OnClickListener{
	/*
	ExpandableListAdapter c_adapter;
	private ExpandableListView grade_exlist;
	List<Map<String,String>> curri_data;
	List<List<Map<String, String>>> curri_content;
	
	String [] kor_subject12 = new String[]{"kor1","kor2"};
	String [][] kor_content12 = new String[][]{
			{"1","2","3"},
			{"2"}
	};
	
	
	String [] eng_subject12 = new String[]{"eng1","eng2"};
	String [][] eng_content12 = new String[][]{
			{"1","2"},
			{"2"}
	};
	
	
	String [] math_subject12 = new String[]{"수와 연산","도형","측정","규칙성","확률과 통계"};
	String [][] math_content12 = new String[][]{
			{"네 자리이하의 수","두자리 수의 덧셈과 뺄셈","곱셈"},
			{"입체 도형의 모양","평면도형의 모양","평면도형과 그 구성요소"},
			{"양의 비교","시각 읽기","시각과 시간","길이"},
			{"규칙 찾기\n - 물체, 무늬, 수"},
			{"분류하기", "표만들기", "그래프 그리기"}
	};
	
	String [] socal_subject12 = new String[]{"사회1","사회2"};
	String [][] socal_content12 = new String[][]{
			{"1","2"},
			{"2"}
	};
	
	*/
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_curriculum);
		
//		Button back_btn = (Button) this.findViewById(R.id.back_btn);
//		back_btn.setOnClickListener(this);
		
		Intent intent = getIntent();
		String msg = intent.getExtras().getString("msg");
		TextView title = (TextView) findViewById(R.id.title);		
		title.setText(msg+" 교육과정"); //title
		//TextView tv = (TextView) findViewById(R.id.subject);
		//tv.setText ("  "+msg);	//subject
		
		if(msg.equals("수학")){
			ImageView iv = (ImageView) this.findViewById(R.id.img_view);
			iv.setImageResource(R.drawable.math);
		}else if(msg.equals("국어")){
			ImageView iv = (ImageView) this.findViewById(R.id.img_view);
			iv.setImageResource(R.drawable.korean);
		}
//		display(msg);
	}
/*
	private void display(String msg) {
		if(msg.trim().equals("kor")){
			String [] str_subject = kor_subject12;
			String [][] str_content = kor_content12;
			curriDisp(str_subject, str_content);
		}else if(msg.trim().equals("eng")){
			String [] str_subject = eng_subject12;
			String [][] str_content = eng_content12;
			curriDisp(str_subject, str_content);
		}else if(msg.trim().equals("math")){
			String [] str_subject = math_subject12;
			String [][] str_content = math_content12;
			curriDisp(str_subject, str_content);
		}else if(msg.trim().equals("soc")){
			String [] str_subject = socal_subject12;
			String [][] str_content = socal_content12;
			curriDisp(str_subject, str_content);
		}
	}

	private void curriDisp(String[] str_subject, String[][] str_content) {
		grade_exlist = (ExpandableListView) findViewById(R.id.grade_list);
		curri_data = new ArrayList<Map<String, String>>();
		curri_content = new ArrayList<List<Map<String, String>>>();
		for(int i=0; i< str_subject.length;i++){
			Map<String, String> mSubject = new HashMap<String, String>();
			mSubject.put("str_subject", "  "+str_subject[i]);
			curri_data.add(mSubject);
			
			List<Map<String, String>> children = new ArrayList<Map<String,String>>();
			
			for(int j=0; j < str_content[i].length; j++){
				Map<String, String> mContent = new HashMap<String, String>();
				mContent.put("str_content", str_content[i][j]);
				children.add(mContent);
			}
			curri_content.add(children);
		}
		
		c_adapter = new SimpleExpandableListAdapter(
				this, 
				curri_data, 
				R.layout.curri_item, 
				new String[] {"str_subject"}, 
				new int[] {R.id.curri_subject}, 
				curri_content, 
				R.layout.curri_contexts_item,
				new String[] {"str_content"}, 
				new int[]{R.id.curri_content}
				);
		grade_exlist.setAdapter(c_adapter);
	}
*/
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.curriculum, menu);
		return true;
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		this.finish();
	}

}
